import 'dart:io';
import 'package:tencent_ad/tencent_ad.dart';
import 'package:flutter/services.dart';
import 'package:flutter/material.dart';
import 'package:device_info/device_info.dart';
class Utils {
  static String getImgPath(String name, {String format: 'png'}) {
    return 'images/$name.$format';
  }

  /**
   * 腾讯广告插件
   */
  static void TencentADPluginInit(String appID){
    TencentADPlugin.config(appID: appID).then(
          (_) => SplashAD(
          posID: '5001912458046595',
          callBack: (event, args) {
            switch (event) {
              case SplashADEvent.onNoAD:
              case SplashADEvent.onADDismissed:
                SystemChrome.setEnabledSystemUIOverlays([
                  SystemUiOverlay.top,
                  SystemUiOverlay.bottom,
                ]);
                SystemChrome.setSystemUIOverlayStyle(
                  SystemUiOverlayStyle(statusBarColor: Colors.transparent),
                );
                break;
              default:
            }
          }).showAD(),
    );
  }

  /**
   * 获取设备ID
   */
  static Future<String> getUniqueId() async {
    DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
    if (Platform.isIOS) {
      IosDeviceInfo iosDeviceInfo = await deviceInfo.iosInfo;
      return  iosDeviceInfo.identifierForVendor; // unique ID on iOS
    } else {
      AndroidDeviceInfo androidDeviceInfo = await deviceInfo.androidInfo;
      return  androidDeviceInfo.androidId;
    }
  }
}